{% extends "common/layout_main.html" %}
{% block js %}
    <script src="{{ buildStaticUrl('/plugins/ueditor/ueditor.config.js') }}"></script>
    <script src="{{ buildStaticUrl('/plugins/ueditor/ueditor.all.min.js') }}"></script>
    <script src="{{ buildStaticUrl('/plugins/ueditor/lang/zh-cn/zh-cn.js') }}"></script>
    <script src="{{ buildStaticUrl('/js/foods/food_set.js') }}"></script>
    <script src="{{ buildStaticUrl('/plugins/select2/select2.pinyin.js') }}"></script>
    <script src="{{ buildStaticUrl('/plugins/select2/zh-CN.js') }}"></script>
    <script src="{{ buildStaticUrl('/plugins/select2/pinyin.core.js') }}"></script>
    <script src="{{ buildStaticUrl('/plugins/tagsinput/jquery.tagsinput.min.js') }}"></script>
{% endblock %}
{% block css %}
    <link rel="stylesheet" href="{{ buildStaticUrl('/plugins/select2/select2.min.css') }}">
    <link rel="stylesheet" href="{{ buildStaticUrl('/plugins/tagsinput/jquery.tagsinput.min.css') }}">
{% endblock %}
{% block content %}
    <div class="row  border-bottom">
        <div class="col-lg-12">
            <div class="tab_title">
                <ul class="nav nav-pills">
                    <li class="current">
                        <a href="{{ buildUrl('/food/index') }}">美食列表</a>
                    </li>
                    <li>
                        <a href="{{ buildUrl('/food/cat') }}">分类列表</a>
                    </li>
                </ul>
            </div>
        </div>
    </div>
    <div class="row mg-t20 wrap_food_set" style="">
        <div class="col-lg-12" style="">
            <h2 class="text-center">设置</h2>
            <div class="form-horizontal m-t" style="">
                <div class="form-group">
                    <label class="col-lg-2 control-label">分类:</label>
                    <div class="col-lg-10">
                        <select name="cat_id" class="form-control select2-hidden-accessible" tabindex="-1"
                                aria-hidden="true">
                            <option value="0">请选择分类</option>
                            {% for cate in cates %}
                                {% if food.cat_id == cate.id %}
                                    <option selected="selected" value="{{ cate.id }}">{{ cate.name }}</option>
                                {% else %}
                                    <option value="{{ cate.id }}">{{ cate.name }}</option>
                                {% endif %}
                            {% endfor %}

                        </select>
                    </div>
                </div>
                <div class="hr-line-dashed"></div>
                <div class="form-group">
                    <label class="col-lg-2 control-label">名称:</label>
                    <div class="col-lg-10">
                        <input type="text" class="form-control" placeholder="请输入名称" name="name"
                               value="{% if food %}{{ food.name }}{% else %}{% endif %}">
                    </div>
                </div>
                <div class="hr-line-dashed"></div>
                <div class="form-group">
                    <label class="col-lg-2 control-label">价格:</label>
                    <div class="col-lg-10">
                        <input type="text" class="form-control" placeholder="请输入售价" name="price"
                               value="{% if food %}{{ food.price }}{% endif %}">
                    </div>
                </div>
                <div class="hr-line-dashed"></div>
                <div class="form-group">
                    <label class="col-lg-2 control-label">封面图:</label>
                    <div class="col-lg-10">
                        <form class="upload_pic_wrap" target="upload_file" enctype="multipart/form-data" method="POST"
                              action="{{ buildUrl('/upload/pic') }}">
                            <div class="upload_wrap pull-left">
                                <i class="fa fa-upload fa-2x"></i>
                                <input type="file" name="pic" accept="image/png, image/jpeg, image/jpg,image/gif">
                            </div>
                            {% if food.main_image %}
                                <span class="pic-each">
                                    <img style="overflow: hidden;margin: auto;height: 100px"
                                         src="{{ buildImageUrl(food.main_image) }}"/>
                                    <span class="fa fa-times-circle del del_image" data="{{ food.main_image }}"></span>
                                </span>
                            {% endif %}
                        </form>
                    </div>
                </div>
                <div class="hr-line-dashed"></div>
                <div class="form-group" style="">
                    <label class="col-lg-2 control-label">描述:</label>
                    <div class="col-lg-10">
                        <div id="container" data-content={% if food %}{{ food.summary }}{% endif %}
                        >
                        </div>
                        {#                        <textarea id="editor" name="summary" style="height: 300px;"></textarea>#}
                    </div>
                </div>
                <div class="hr-line-dashed"></div>
                <div class="form-group">
                    <label class="col-lg-2 control-label">库存:</label>
                    <div class="col-lg-2">
                        <input type="text" name="stock" class="form-control"
                               value="{% if food %}{{ food.stock }}{% endif %}">
                    </div>
                </div>
                <div class="hr-line-dashed"></div>
                <div class="form-group">
                    <label class="col-lg-2 control-label">标签:</label>
                    <div class="col-lg-10">
                        <input type="text" class="form-control" name="tags"
                               value="{% if food %}{{ food.tags }}{% endif %}">
                    </div>
                </div>
                <div class="hr-line-dashed"></div>
                <div class="form-group">
                    <div class="col-lg-4 col-lg-offset-2">
                        <input type="hidden" name="id" value="0">
                        <button class="btn btn-w-m btn-outline btn-primary save"
                                data-id="{% if food %}{{ food.id }}{% endif %}">保存
                        </button>
                    </div>
                </div>
            </div>
        </div>
    </div>
    {#  设置隐藏的iframe用来隐式提交上传数据，iframe的name必须要和对应地方的form表单的target所对应  #}
    <iframe name="upload_file" class="hide"></iframe>
{% endblock %}
